<template>
  <div class="excellentCourse">
    <div class="bread">
      <el-breadcrumb separator=">">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item :to="{ path: '#' }">书法教学</el-breadcrumb-item>
        <el-breadcrumb-item>双师课堂</el-breadcrumb-item>
      </el-breadcrumb>
    </div>

    <div class="search">
      <div class="desc">年级</div>
      <div>
        <el-radio-group v-model="queryParams.grade" fill="#00a556" @input="reQuery">
          <el-radio-button label="0">全部</el-radio-button>
          <el-radio-button v-for=" (item,index) in dict.type.school_book_grade " :key="index" :label="item.value">
            {{ item.label }}
          </el-radio-button>
        </el-radio-group>
      </div>
    </div>
    <div class="courseList">
      <div class="item" v-for="(item,index) in courseList"  :key="item.id">
        <router-link :to="{name:'shuangShiDetail', query: {id:item.id}}" target="_blank">
          <div class="item-box">
            <div class="item-img">
              <image-none-preview :src="item.cover"></image-none-preview>
            </div>
            <div class="designType">
              {{ selectDictLabel(dict.type.school_book_grade, item.grade) }}
            </div>
            <div class="title">
              <h4>{{ item.title }}</h4>
            </div>
            <div class="desc">
              {{ cutString (item.introduction, 50) }}
            </div>
          </div>
        </router-link>
      </div>
    </div>
    <div class="page">
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
  </div>
</template>

<script>

import { listShuangshi } from '@/api/teach/shuangshi/shuangshi'
import ImageNonePreview from '@/components/ImagePreview/ImageNonePreview.vue'
import { cutString } from '@/utils/ruoyi'
export default {
  name: 'ShuangShiPage',
  components: { ImageNonePreview },
  dicts: ['school_book_grade'],
  data () {
    return {
      total: 0,
      courseList: [],
      queryParams: {
        pageNum: 1,
        pageSize: 6,
        grade:'0'
      },
    }
  },
  created () {
    this.getList()
  },
  methods: {
    cutString,
    getList () {
      this.loading = true
      listShuangshi(this.queryParams).then(response => {
        this.courseList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    reQuery () {
      this.getList()
    }
  }
}
</script>

<style lang="scss" scoped>

.excellentCourse {
  text-align: center;
}

.search {
  margin-top: 20px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 15px;

  .desc {
    margin-right: 40px;
    font-size: 16px;
    line-height: 26px;
    font-weight: 600;
  }
}

.courseList {
  margin-top: 20px;
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;

  .item {
    position: relative;
    float: left;
    width: 382px;
    height: 365px;
    margin-right: 15px;
    margin-bottom: 15px;
  }

  .item-box {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #FFFFFF;
    border-radius: 6px;
    box-shadow: 0px 6px 40px 0px rgba(34, 87, 179, 0.12);
    padding: 4.47%;
    box-sizing: border-box;
    overflow: hidden;
    text-align: center;
  }

  .item-img {
    width: 100%;
    height: 250px;
    border-radius: 5px;
    overflow: hidden;

  }

  .title {
    position: relative;
    font-size: 16px;
    color: #696E81;
    text-align: left;
    margin-top: 15px;
  }

  .desc {
    margin-top: 5px;
    font-size: 14px;
    color: #666666;
    text-align: left;
    line-height: 2;
  }


  .designType {
    position: absolute;
    width: 72px;
    height: 30px;
    line-height: 30px;
    border-radius: 4px;
    font-weight: 500;
    background: #00a556;
    color: #FFFFFF;
    left: 24px;
    bottom: 95px
  }
}

.page {
  text-align: center;
  margin-top: 30px;

  ::v-deep .number.active {
    background-color: #337ab7 !important;
  }
}
</style>
